package com.yxhl.zoume.domain.interactor.usercenter;

import com.yxhl.zoume.data.http.repository.usercenter.UserCenterRepository;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.param.usercenter.LogoutParam;
import com.yxhl.zoume.data.http.rest.response.usercenter.LogoutResponse;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.UseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by vhawk on 16/4/12.
 */
public class LogoutUseCase extends UseCase<LogoutResponse> {

    private UserCenterRepository repository;

    @Inject
    public LogoutUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                         @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                         UserCenterRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<LogoutResponse> buildObservable(RequestParamImpl param) {
        return repository.logout((LogoutParam) param)
                .observeOn(uiThread)
                .subscribeOn(executorThread);
    }
}
